package com.example.result.dao.vo

import androidx.room.*
import androidx.room.ForeignKey.Companion.CASCADE
//import androidx.room.ForeignKey.CASCADE
import com.google.gson.annotations.SerializedName
@Entity(tableName = "daodejingSection")
data class DaoSection(
    @PrimaryKey
    @SerializedName("id")
    val id: Int,
    @SerializedName("name")
    val name: String,
    @SerializedName("wu")
    val wu: String?

) {
    @SerializedName("data")
    @Ignore
    var data: List<DaoContent> = emptyList<DaoContent>()
}

@Entity(
    tableName = "daodejingContent", primaryKeys = ["id", "sectionId"],
    foreignKeys = [ForeignKey(
        entity = DaoSection::class,
        parentColumns = ["id"],
        childColumns = ["sectionId"],
        onUpdate = CASCADE, onDelete = ForeignKey.CASCADE,
        deferred = true
    )],
    indices = [Index(value = ["sectionId"], unique = true)]
)
data class DaoContent(
    @SerializedName("id")
    val id: Int,
    @SerializedName("content")
    val content: String,
    @SerializedName("sectionId")
    var sectionId: Int = 0,
    @SerializedName("wu")
    val wu: String?
) {

}

data class DaoDatas(
    @SerializedName("count")
    val count: Int,
    @SerializedName("has_next")
    val hasNext: Int,
    @SerializedName("data")
    val data: List<DaoSection>
)